﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            string conString = "server=.;database=wyl;uid=sa;pwd=123123";
            SqlConnection sqlConnection = new SqlConnection(conString );
            string cmdString = "select * from Students";
            SqlDataAdapter dateAdapter = new SqlDataAdapter(cmdString, sqlConnection);

            DataTable dt = new DataTable();
            sqlConnection.Open();

            dateAdapter.Fill(dt);
            dataGridView1.DataSource = dt;

        }
    }
}
